package com.cl.code.database.mybatis.module.sql;


/**
 * @author chengliang
 * @since 1.0.0
 */
public class Select<Entity> {
    private final Class<Entity> entityClass;
    private View<Entity> view;
    private Where<Entity> where;
    private Order<Entity> order;

    private Select(Class<Entity> entityClass) {
        this.entityClass = entityClass;
    }

    public static <Entity> Select<Entity> of(Class<Entity> tClass) {
        return new Select<>(tClass);
    }

    public Class<Entity> getEntityClass() {
        return this.entityClass;
    }

    public Where<Entity> where() {
        if (this.where == null) {
            this.where = Where.of(entityClass);
        }
        return this.where;
    }

    public Order<Entity> order() {
        if (this.order == null) {
            this.order = Order.of(entityClass);
        }
        return this.order;
    }

    public View<Entity> view() {
        if (this.view == null) {
            this.view = View.of(entityClass);
        }
        return this.view;
    }

}
